<?php

class Application_Model_DbTable_RepayLink extends Application_Model_DbTable_DomainObject{
    
    protected $_name = 'uuch_repayLink';
    
    public function getMapper() {
        return array('id','name','repayMoney','description','dateCreated','datePaid','type','relationId','link','userId','status');
    }

    /*
    * 获取总金额
    */
    public function  getSumMoney($relationId, $type)
    {
        $re = false;
        if(!empty($relationId) && !empty($type)){
            $db  = $this->getAdapter();
            $sql = 'SELECT SUM(repayMoney) as money FROM uuch_repayLink WHERE STATUS = 1 AND TYPE = '. $type .' AND relationId = ' . $relationId;
            $result = $db->query($sql);

            $re = $result->fetchColumn();
        }
        return $re;
    }
}